#include<stdio.h>
#include<stdlib.h>

typedef struct C_ListNode
{
    int val;
    struct C_ListNode *next;
}C_ListNode;

C_ListNode *NewNode(int val);
void print_link(C_ListNode *head);

int main()
{
    // 初始化链表 1 -> 3 -> 2 -> 5 -> 4 
    int size,val;
    printf("input size:");
    scanf("%d", &size);

    printf("input[0]val:");
    scanf("%d", &val);
    C_ListNode *head = NewNode(val);
    C_ListNode *tail = head;

    for (int i = 1; i < size; i++)
    {
        printf("input[%d]val:", i);
        scanf("%d", &val);
        C_ListNode *p = NewNode(val);

        tail->next = p;
        tail = p;
    }
    tail->next = head;

    // 输出链表
    print_link(head);
}

C_ListNode *NewNode(int val)
{
    C_ListNode *p = (C_ListNode *)malloc(sizeof(C_ListNode));
    p->val = val;
    p->next = NULL;
    return p;
}
// 输出链表
void print_link(C_ListNode *head)
{
    C_ListNode *p = head;
    while (p->next != head)
    {
        printf("%d<->", p->val);
        p = p->next;
    }
    printf("%d<->\n", p->val);
}